<!-- 走马灯 -->
<template>
  <div>
    <div class="block">
    <el-carousel trigger="click" height="150px" arrow="never">
      <el-carousel-item v-for="item in 3" :key="item">
        <button @click="showGoods">
          <img :src="imgURL+item"/>
        </button>
      </el-carousel-item>
    </el-carousel>
  </div>
  </div>
</template>

<script>
  export default {
  data() {
    return {
      
    }
  },
  //生命周期 - 创建完成（访问当前this实例）
  methods:{
    showGoods(){
      console.log('商品展示')
    }
  },
  computed:{
    imgURL(){
      return "https://picsum.photos/"+ document.body.clientWidth + "/150?random="
    }
  },
  created() {
  
  },
  //生命周期 - 挂载完成（访问DOM元素）
  mounted() {
  
  }
  }
</script>
<style scoped>
/* @import url(); 引入css类 */
  .el-carousel__item h3 {
    color: #475669;
    font-size: 14px;
    opacity: 0.75;
    line-height: 150px;
    margin: 0;
  }

  .el-carousel__item:nth-child(2n) {
    background-color: #99a9bf;
  }
  
  .el-carousel__item:nth-child(2n+1) {
    background-color: #d3dce6;
  }
</style>